package com.hxd.otc.module.fiat_deal.fragment;

import android.content.Intent;
import android.os.Bundle;

import com.hxd.otc.R;
import com.hxd.otc.base.BaseRecyclerActivity;
import com.hxd.otc.module.fiat_deal.adapter.SelectFiatAdapter;
import com.hxd.otc.module.fiat_deal.bean.SelectFiatBean;
import com.hxd.otc.module.fiat_deal.contract.SelectFiatContract;
import com.hxd.otc.module.fiat_deal.presenter.SelectFiatPresenter;

import java.util.ArrayList;

/**
 * Created by lzy on 2018/9/17 0017.
 * description ${选择法币}
 */
public class SelectFiatActivity extends BaseRecyclerActivity<SelectFiatPresenter, SelectFiatAdapter, SelectFiatBean> implements SelectFiatContract.IView {
    public static final String EXTRA_SELECTED_FIAT = "selected_fiat";
    public static final String RESULT_EXTRA_SELECTED_FIAT = "new_selected_fiat";
    public static final String EXTRA_FAILTS = "failts";
    ArrayList<String> failts;
    Bundle bundle;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_select_fiat;
    }

    @Override
    protected SelectFiatAdapter createAdapter() {
        String selectedFiat = "CNY";
        if (bundle != null) {
            selectedFiat = bundle.getString(EXTRA_SELECTED_FIAT);
        }
        SelectFiatAdapter selectFiatAdapter = new SelectFiatAdapter(this);
        selectFiatAdapter.setSelectedFiat(selectedFiat);
        return selectFiatAdapter;
    }

    @Override
    protected SelectFiatPresenter createPresenter() {
        bundle = getBundle();
        failts = bundle.getStringArrayList(EXTRA_FAILTS);
        return new SelectFiatPresenter(this, failts);
    }

    @Override
    public void onItemClick(int position) {
        Intent intent = new Intent();
        intent.putExtra(RESULT_EXTRA_SELECTED_FIAT, mAdapter.getItem(position).getFiat());
        setResult(RESULT_OK, intent);
        finish();
    }

    @Override
    public boolean isEnableLoadMore() {
        return false;
    }
}
